//
//  MineFuncItemVMNew.swift
//  kxf
//
//  Created by LNS2 on 2024/4/21.
//

import Foundation
import UIKit

class MineFuncItemVMNew: UIView {
    
    let selfWidth = kFitWidth(90)
    let selfHeight = kFitWidth(78)
    
    var typeString = ""
    var tapBlock:((String)->())?
    
    override init(frame:CGRect){
        super.init(frame: CGRect.init(x: frame.origin.x, y: frame.origin.y, width: selfWidth, height: selfHeight))
        self.backgroundColor = .clear
        self.isUserInteractionEnabled = true
        
        let tap = UITapGestureRecognizer.init(target: self, action: #selector(tapAction))
        self.addGestureRecognizer(tap)
        
        initUI()
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    lazy var imgView : UIImageView = {
        let img = UIImageView()
        img.isUserInteractionEnabled = true
        
        return img
    }()
    lazy var contentLabel : UILabel = {
        let lab = UILabel()
        lab.textColor = .black
        lab.font = .systemFont(ofSize: 14, weight: .regular)
        lab.textAlignment = .center
        
        return lab
    }()
}

extension MineFuncItemVMNew{
    @objc func tapAction() {
        if self.tapBlock != nil{
            self.tapBlock!(self.typeString)
        }
    }
}

extension MineFuncItemVMNew{
    func initUI() {
        addSubview(imgView)
        addSubview(contentLabel)
        
        imgView.snp.makeConstraints { make in
            make.top.equalTo(kFitWidth(14))
            make.width.height.equalTo(kFitWidth(40))
            make.centerX.lessThanOrEqualToSuperview()
        }
        contentLabel.snp.makeConstraints { make in
            make.bottom.equalToSuperview()
            make.centerX.lessThanOrEqualToSuperview()
        }
    }
}
